<cfprocessingdirective suppresswhitespace="true">
<cfparam name="attributes.table_name" default="" />
<cfinclude template="qry_db_objects.cfm" />
<cfinclude template="qry_ref_objects.cfm" />

<cfscript>
	/*
	****************** VARIABLES ******************
	*/
	l = '<';
	genContent = '_generatedContent/';
	lstTable = ValueList(rs.table_name);

	// set my path as the current directory we're running from?
	myPath = GetDirectoryFromPath(GetCurrentTemplatePath());
	
	// crea, upda, dele, selec
	//sqlAction = 'selec';
	lstSqlAction = 'crea,upda,dele,selec,frm_modify,index,dsp_all,frm_filter';
</cfscript>

<table class="report">
<cftry>
<!--- deleting all files in generated content directory --->
<cfdirectory action = "delete" directory = "#myPath##genContent#" recurse="yes" />
<cfscript>writeRow('deleting all files in generated content directory','');</cfscript>
<cfcatch><cfscript>writeRow('#cfcatch.message# - #cfcatch.detail#','');</cfscript></cfcatch>
</cftry>

<cfscript>writeRow('using path',myPath);</cfscript>

<!--- loop through each table --->
<cfoutput query="rs" group="Table_Name">
	<cfloop list="#lstSqlAction#" index="sqlAction">
	<cfsavecontent variable="qry">
		<!--- header --->
			<cfswitch expression="#sqlAction#">
			
			<!--- select query --->
			<cfcase value="selec">
			<cfset fileName = "qry.cfm" />
			<cfinclude template="code/head.cfm" />
			SELECT
				TOP ##request.MAXROWS##
				NULL AS [0]<cfoutput>
				, #left(Table_Name,1)#.[#column_name#]</cfoutput>
			FROM
				[#Table_Name#] AS #left(Table_Name,1)#
			WHERE
				1=1
				#l#cfif CGI.SCRIPT_NAME CONTAINS "/#tabName(table_name)#/">
				<cfoutput><cfif is_identity eq 'Y'><!--- assuming that we will be searching on the identity --->
				#l#cfif isDefined("attributes.#column_name#") and attributes.#column_name# neq "">
				AND #left(Table_Name,1)#.[#column_name#] = #l#cfqueryparam value="##attributes.#column_name###" cfsqltype="cf_sql_#getDT(data_type)#" <cfif isTextCol(data_type)>maxlength="#length#"</cfif> null="<cfif is_nullable eq 'Y'>##isEmpty(attributes.#column_name#)##<cfelse>NO</cfif>" />
				#l#/cfif></cfif></cfoutput>
					#l#cfif isDefined("attributes.q") and attributes.q neq "">
						#l#cfloop list="##attributes.q##" index="w" delimiters=" ">
						AND ''	<cfoutput><cfif data_type eq "varchar">
							+ COALESCE(#left(Table_Name,1)#.[#column_name#],'')</cfif></cfoutput>
							LIKE #l#cfqueryparam cfsqltype="cf_sql_varchar" value="%##w##%" />
						#l#/cfloop>
					#l#/cfif>
				#l#/cfif>
			ORDER BY
				1
				, 2
			<cfinclude template="code/foot.cfm" />
			</cfcase>
			
			<!--- update query --->
			<cfcase value="upda">
			<cfset fileName = "act_#sqlAction#te.cfm" />
<cfoutput>
#l#cfparam name="attributes.#column_name#" default="<cfif data_type eq "bit">0</cfif>" />
</cfoutput>
			<cfinclude template="code/head.cfm" />
			UPDATE
				[#Table_Name#]
			SET
				NULL AS [0]
				<cfoutput><cfif is_identity neq 'Y'>, [#column_name#] =  #l#cfqueryparam value="##attributes.#column_name###" cfsqltype="cf_sql_#getDT(data_type)#" <cfif isTextCol(data_type)>maxlength="#length#"</cfif> null="<cfif is_nullable eq 'Y'>##isEmpty(attributes.#column_name#)##<cfelse>NO</cfif>" />
				</cfif></cfoutput>
			WHERE
				1=1<cfoutput><cfif is_identity eq 'Y'>
				AND [#column_name#] = #l#cfqueryparam value="##attributes.#column_name###" cfsqltype="cf_sql_#getDT(data_type)#" <cfif isTextCol(data_type)>maxlength="#length#"</cfif> null="<cfif is_nullable eq 'Y'>##isEmpty(attributes.#column_name#)##<cfelse>NO</cfif>" /></cfif></cfoutput>
			<cfinclude template="code/foot.cfm" />
			</cfcase>
			
			<!--- insert query --->
			<cfcase value="crea">
			<cfset fileName = "act_#sqlAction#te.cfm" />
<cfoutput>
#l#cfparam name="attributes.#column_name#" default="<cfif data_type eq "bit">0</cfif>" /></cfoutput>
			<cfinclude template="code/head.cfm" />
			INSERT INTO [#Table_Name#] (
				NULL AS [0]
				<cfoutput><cfif is_identity neq 'Y'>, [#column_name#]
				</cfif></cfoutput>
			) VALUES (
				NULL AS [0]
				<cfoutput><cfif is_identity neq 'Y'>, #l#cfqueryparam value="##attributes.#column_name###" cfsqltype="cf_sql_#getDT(data_type)#" <cfif isTextCol(data_type)>maxlength="#length#"</cfif> null="<cfif is_nullable eq 'Y'>##isEmpty(attributes.#column_name#)##<cfelse>NO</cfif>" />
				</cfif></cfoutput>
			)
			<cfinclude template="code/foot.cfm" />
			</cfcase>
			
			<!--- delete query --->
			<cfcase value="dele">
			<cfset fileName = "act_#sqlAction#te.cfm" />
			<cfinclude template="code/head.cfm" />
			DELETE
				[#Table_Name#]
			WHERE
				0=1<cfoutput><cfif is_identity eq 'Y'>
				OR [#column_name#] = #l#cfqueryparam value="##attributes.#column_name###" cfsqltype="cf_sql_#getDT(data_type)#" <cfif isTextCol(data_type)>maxlength="#length#"</cfif> null="<cfif is_nullable eq 'Y'>##isEmpty(attributes.#column_name#)##<cfelse>NO</cfif>" /></cfif></cfoutput>
			<cfinclude template="code/foot.cfm" />
			</cfcase>
			
			<!--- frm_filter.cfm --->
			<cfcase value="frm_filter">
			<cfset fileName = "#sqlAction#.cfm" />
			<cfinclude template="code/comment.cfm" />
<!--- begin frm_filter.cfm --->

#l#!--- reference tables ---><cfsilent>
<cfquery name="rsRefQry" dbtype="query">
	SELECT 
		table_name
		, ref_table_name
		, column_name
	FROM
		rsRef
	WHERE
		table_name = <cfqueryparam cfsqltype="cf_sql_varchar" value="#rs.Table_Name#" />
</cfquery>
<cfset lstRefColumn = ValueList(rsRefQry.column_name) />
<cfset lstRefTable = ValueList(rsRefQry.ref_table_name) />
</cfsilent>
<cfloop query="rsRefQry">
#l#cfparam name="attributes.#rsRefQry.column_name#" default="" />
#l#cfinclude template="../#tabName(rsRefQry.ref_table_name)#/qry.cfm" /></cfloop>

#l#cfoutput>
	<form name="frmFilter" id="frmFilter" class="filter" method="get">
		<div>
			<label for="q">
				Search:
			</label>
			<input name="q" id="q" value="##attributes.q##" maxlength="50" size="20" />
		</div>
		
		<cfoutput><cfif ListFind(lstRefColumn,column_name) gt 0>
		<cfsilent>
			<cfscript>
				listPos = ListFind(lstRefColumn,column_name);
				refTable = tabName(ListGetAt(lstRefTable,listPos));
			</cfscript>
		</cfsilent>
		<div>
			<label for="#column_name#">
				#Replace(dspFormat(column_name),"##","####")#:
			</label>
			<select name="#column_name#" id="#column_name#">
				<option value="">-All-</option>
				#l#cfloop query="rs_#refTable#">
				<option value="##rs_#refTable#.#column_name###" #l#cfif attributes.#column_name# eq rs_#refTable#.#column_name#>
					selected#l#/cfif>>#l#cftry>##rs_#refTable#.#Replace(column_name,'_id','_name')####l#cfcatch>#l#cftry>##rs_#refTable#.#Replace(column_name,'_id','_desc')####l#cfcatch>##rs_#refTable#.#column_name####l#/cfcatch>#l#/cftry>#l#/cfcatch>#l#/cftry></option>
				#l#/cfloop>
			</select>
		</div>
		</cfif></cfoutput>
		
		<div>
			<label for="recsPerPage">
				Recs per page:
			</label>
			<select name="recsPerPage" id="recsPerPage">
				#l#cfloop list="#request.lstRecsPerPage#" index="i">
					<option value="##i##" #l#cfif isDefined("attributes.recsPerPage") and i eq attributes.recsPerPage>selected#l#/cfif>>##i##</option>
				#l#/cfloop>
			</select>
		</div>
		
		<div class="actionButtons">
			<input type="submit" value="Search" class="button" />
			<input type="reset" value="Reset" class="button" />
		</div>
		<br clear="all" />
	</form>
#l#/cfoutput>	
<!--- end frm_filter.cfm --->		
			</cfcase>
			
			<!--- frm_modify.cfm --->
			<cfcase value="frm_modify">
			<cfset fileName = "#sqlAction#.cfm" />
			<cfinclude template="code/comment.cfm" />
<!--- begin frm_modify.cfm --->
#l#cfsilent>
#l#cfparam name="actionPage" default="" />
#l#cfparam name="myAct" default="" />
<cfoutput><cfif is_identity eq 'Y'>#l#cfparam name="attributes.#column_name#" <cfif data_type eq "int"> default="0"</cfif> />

#l#cfscript>
	actionPage = 'act_update.cfm';
	myAct = 'Update';
	if (val(attributes.#column_name#) eq 0) {
		actionPage = 'act_create.cfm';
		myAct = 'New';
	}
#l#/cfscript>
</cfif></cfoutput>
#l#cfinclude template="qry.cfm" />

#l#!--- reference tables ---><cfsilent>
<cfquery name="rsRefQry" dbtype="query">
	SELECT 
		table_name
		, ref_table_name
		, column_name
	FROM
		rsRef
	WHERE
		table_name = <cfqueryparam cfsqltype="cf_sql_varchar" value="#rs.Table_Name#" />
</cfquery>
<cfset lstRefColumn = ValueList(rsRefQry.column_name) />
<cfset lstRefTable = ValueList(rsRefQry.ref_table_name) />
</cfsilent>
<cfloop query="rsRefQry">
#l#cfinclude template="../#tabName(rsRefQry.ref_table_name)#/qry.cfm" /></cfloop>

#l#/cfsilent>

#l#form method="post" name="form_#tabName(Table_Name)#" id="form_#tabName(Table_Name)#" action="#l#cfoutput>##actionPage###l#/cfoutput>" onSubmit="return checkForm(this);">	
<cfoutput><cfif is_identity eq 'Y'>
#l#input type="hidden" name="#column_name#" id="#column_name#" value="#l#cfoutput>##rs_#tabName(Table_Name)#.#column_name####l#/cfoutput>">
</cfif></cfoutput>

	#l#table class="userInput">
		#l#caption>
			#l#cfoutput>##myAct###l#/cfoutput> #dspFormat(Table_Name)#
		#l#/caption>
		#l#tbody>
			<cfoutput>
			<cfif is_identity neq 'Y'>
				<cfswitch expression="#data_type#">
					<cfcase value="varchar,char,int,smallint,tinyint,decimal,money">
						#l#tr>
							#l#td>
								#l#label for="#column_name#"<cfif is_nullable eq "N"> class="required"</cfif>>#dspFormat(column_name)#:#l#/label>
							#l#/td>
							#l#td>
								<cfif ListFind(lstRefColumn,column_name) gt 0>
									<!--References another table... -->
									<cfsilent>
									<cfscript>
										listPos = ListFind(lstRefColumn,column_name);
										refTable = tabName(ListGetAt(lstRefTable,listPos));
									</cfscript>
									</cfsilent><!--- found in reference query so make a drop-down list --->
									#l#select name="#column_name#" id="#column_name#"
										<cfif is_nullable eq "N">required="true"</cfif>>
										#l#option value="">- All -#l#/option>
										#l#cfoutput query="rs_#refTable#">
											#l#option value="##rs_#refTable#.#column_name###" #l#cfif (isDefined("rs_#tabName(Table_Name)#.#column_name#") AND rs_#refTable#.#column_name# EQ rs_#tabName(Table_Name)#.#column_name#)>selected="selected"#l#/cfif>>#l#cftry>##rs_#refTable#.#Replace(column_name,'_id','_name')####l#cfcatch>#l#cftry>##rs_#refTable#.#Replace(column_name,'_id','_desc')####l#cfcatch>##rs_#refTable#.#column_name####l#/cfcatch>#l#/cftry>#l#/cfcatch>#l#/cftry>#l#/option>
										#l#/cfoutput>
									#l#/select>
									<cfelse><!--- simple text input --->
									#l#input name="#column_name#" id="#column_name#" 
										<cfif is_nullable eq "N">required="true"
										</cfif><cfif data_type CONTAINS "int">onKeyPress="return allowChar(this,numChars,event);"
										</cfif><cfif column_name CONTAINS 'phone' 
												OR column_name CONTAINS 'fax'>onKeyPress="return allowChar(this,numChars,event);"
										</cfif>type="<cfif column_name CONTAINS 'password' 
												OR column_name CONTAINS 'pwd'>password<cfelse>text</cfif>" value="#l#cfoutput>##rs_#tabName(Table_Name)#.#column_name####l#/cfoutput>"
										size="#min(32,length)#" maxlength="#length#" />
								</cfif>
							#l#/td>
						#l#/tr>
					</cfcase>
					<cfcase value="datetime,smalldatetime">
						#l#tr>
							#l#td>
								#l#label for="#column_name#"<cfif is_nullable eq "N"> class="required"</cfif>>#dspFormat(column_name)#:#l#/label>
							#l#/td>
							#l#td>
								<cfif isDefined("cookie.useCustomTagDate") and cookie.useCustomTagDate eq 1>
								#l#cf_date_sel name="#column_name#" id="#column_name#" validate="date"
									style="" label="" <cfif is_nullable eq "N">required="true"</cfif>
									onKeyPress="return allowChar(this,dateChars,event);"
									value="##LSDateFormat(rs_#tabName(Table_Name)#.#column_name#,request.dtFrmt)##" />
								<cfelse>
								#l#input name="#column_name#" id="#column_name#" 
									<cfif is_nullable eq "N">required="true"</cfif>
									onKeyPress="return allowChar(this,dateChars,event);"
									type="text" validate="date" value="#l#cfoutput>##LSDateFormat(rs_#tabName(Table_Name)#.#column_name#,request.dtFrmt)###l#/cfoutput>"
									size="10" maxlength="10" />
									#l#cfoutput>##calLink('#column_name#')###l#/cfoutput>
								</cfif>
							#l#/td>
						#l#/tr>
					</cfcase>
					<cfcase value="text,ntext">
						#l#tr>
							#l#td>
								#l#label for="#column_name#">#dspFormat(column_name)#:#l#/label>
							#l#/td>
							#l#td>
								#l#textarea name="#column_name#" id="#column_name#" 
									class="fck basic">#l#cfoutput>##rs_#tabName(Table_Name)#.#column_name####l#/cfoutput>#l#/textarea>
							#l#/td>
						#l#/tr>
					</cfcase>
					<cfcase value="bit">
						#l#tr>
							#l#td />
							#l#td>
								#l#label for="#column_name#" class="inline">
									#l#input type="checkbox" name="#column_name#" id="#column_name#" value="1"
										#l#cfif val(rs_#tabName(Table_Name)#.#column_name#)>checked#l#/cfif>
										/>
								#dspFormat(column_name)##l#/label>
							#l#/td>
						#l#/tr>
					</cfcase>
					<cfdefaultcase>
						UNHANDLED DATA TYPE: #column_name# #data_type#
					</cfdefaultcase>
				</cfswitch>
			</cfif>
			</cfoutput>
		#l#/tbody>
		#l#tfoot>
			#l#tr>
				#l#td />
				#l#td>
					#l#!--- <div class="actionButtons"> 
						<div id="quickNote">^ Bold Items are REQUIRED</div>
					--->
					#l#input type="submit" value="Submit" class="button" accesskey="S" />
					#l#input type="button" value="Cancel" class="button" onclick="cancelModify()" />
					#l#!--- </div> --->
				#l#/td>
			#l#/tr>
		#l#/tfoot>
	#l#/table>
#l#/form>
<!--- end frm_modify.cfm --->
			</cfcase>
			
			<!--- index.cfm --->
			<cfcase value="index">
			<cfset fileName = "#sqlAction#.cfm" />
			<cfinclude template="code/comment.cfm" />
<cfinclude template="code/index.cfm" />
			</cfcase>
			
			<!--- dsp_all.cfm --->
			<cfcase value="dsp_all">
			<cfset fileName = "#sqlAction#.cfm" />
			<cfinclude template="code/comment.cfm" />
<!--- begin dsp_all.cfm --->
#l#cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
#l#cfinclude template="qry.cfm" />
<cfoutput>
<cfif is_identity eq 'Y'>
<!---#l#cfoutput>--->
	#l#a href="frm_modify.cfm?#column_name#=0" class="button">New #dspFormat(column_name)##l#/a>
<!---#l#/cfoutput>---><br clear="all" />
</cfif>
</cfoutput>

#l#cf_dsp_results_nav rs="##rs_#tabName(Table_Name)###" recsPerPage="##attributes.recsPerPage##" />
<table class="sortable report">
	<caption>
	#l#cfoutput> ##request.filter## #l#/cfoutput>
	</caption>
	<thead>
		<tr>
			<cfoutput><cfif is_identity eq 'Y'>#l#cfif isAdmin()><th sort="false" class="act">act</th>#l#/cfif><cfelse><th>#dspFormat(column_name)#</th></cfif>
			</cfoutput>
		</tr>
	</thead>
	<tbody>
		#l#cfoutput query="rs_#tabName(Table_Name)#" startRow="##request.StartRow##" maxRows="##request.MaxRows##">
			<tr>
				<cfoutput>
				<cfif is_identity eq 'Y'>
				#l#cfif isAdmin()>
				<td>
				<a href="../#tabName(Table_Name)#/frm_modify.cfm?#column_name#=##rs_#tabName(Table_Name)#.#column_name###" class="update icon" title="Update record">update record</a> 
				<a href="../#tabName(Table_Name)#/act_delete.cfm?#column_name#=##rs_#tabName(Table_Name)#.#column_name###" class="delete icon" title="Delete record" onClick="return confirmDelete();">delete record</a>
				</td>
				#l#/cfif>
				<cfelse>
				<td<cfif data_type CONTAINS "datetime"
						OR data_type CONTAINS "int"> class="numeric"</cfif>><cfif data_type CONTAINS "datetime">##LSDateFormat(rs_#tabName(Table_Name)#.#column_name#,request.dtFrmt)##<cfelse>##rs_#tabName(Table_Name)#.#column_name###</cfif></td>
				</cfif>
				</cfoutput>
			</tr>
		#l#/cfoutput>
	</tbody>
</table>
<!--- end dsp_all.cfm --->
			</cfcase>
			
			</cfswitch>
		
	</cfsavecontent>
	
	<cfif not DirectoryExists("#myPath##genContent#")>
		<cfscript>writeRow('creating directory',genContent);</cfscript>
		<cfdirectory action="create" directory="#myPath##genContent#" />
	</cfif>

	<cfif not DirectoryExists("#myPath##genContent##tabName(Table_Name)#/")>
		<cfscript>writeRow('creating directory','#genContent##tabName(Table_Name)#/');</cfscript>
		<cfdirectory action="create" directory="#myPath##genContent##tabName(Table_Name)#/" />
	</cfif>
	
	<cfscript>writeRow('writing file','#genContent##tabName(Table_Name)#/#fileName#');</cfscript>
	<cffile action="write" file="#myPath##genContent##tabName(Table_Name)#/#fileName#" output="#genTrim(qry)#" />
	</cfloop>
</cfoutput>

<!---SINGLE FILES--->

<!--- Application.cfm --->
<cfset fileName = "Application.cfm" />
<cfsavecontent variable="myContent">
<cfoutput>
#l#cfsilent>
#l#!---
#l#cfif FileExists(GetDirectoryFromPath(GetCurrentTemplatePath())&"..\Application.cfm")>
	#l#cfinclude template="../Application.cfm" />
#l#/cfif>
--->
#l#cfapplication
	name="#request.appName#"
	sessionmanagement="true" sessiontimeout="#CreateTimeSpan(0,1,0,0)#">
#l#cfscript>
	//request.appHome = ;
	request.appName = '#request.appName#';
	request.dsn = '#request.dsn#';
	if(CGI.SERVER_NAME eq "localhost") {
		request.appHome = '#request.appHome#_generatedContent/';
	}
	
	request.dtFrmt = 'mm/dd/yyyy';
	request.tmFrmt = 'h:mm tt';
	request.MAXROWS = 1000;
	
	// take url & form scopes and combine them
	if(not isDefined('attributes')) {
		attributes = StructNew();
	}
	StructAppend(attributes, url, true);
	StructAppend(attributes, form, true);
	
	function isAdmin() {
		return true;
	}
	function isEmpty(str) {
		if(trim(str) eq 0) {
			return true;
		}
		return false;
	}

#l#/cfscript>
#l#cfparam name="attributes.cachetime" default="#CreateTimeSpan(1,0,0,0)#" />
#l#cfparam name="attributes.debug" default="0" />
#l#cfparam name="attributes.recsPerPage" default="50" />
#l#cfparam name="attributes.q" default="" />
#l#/cfsilent>
#l#cfoutput>
	<script language="javascript" src="##request.appHome##js/ajax.js"></script>
	<script language="javascript" src="##request.appHome##js/sorttable.js"></script>
	<script language="javascript" src="##request.appHome##js/stripetable.js"></script>
	<script language="javascript" src="##request.appHome##js/validation.js"></script>
	<script language="javascript" src="##request.appHome##js/script.js"></script>
	<link rel="stylesheet" type="text/css" href="##request.appHome##css/style.css" />
#l#/cfoutput>
#l#cfif not isDefined("attributes.ajax")>
#l#cfinclude template="header.cfm" />
#l#/cfif>
</cfoutput>
</cfsavecontent>
<cfscript>writeRow('writing #fileName# file','#genContent##fileName#');</cfscript>
<cffile action="write" file="#myPath##genContent##fileName#" output="#genTrim(myContent)#" />

<!--- index.cfm - create index file main page...--->
<cfset fileName = "index.cfm" />
<cfsavecontent variable="myContent">
<!-- Main -->
</cfsavecontent>
<cfscript>writeRow('writing #fileName# file','#genContent##fileName#');</cfscript>
<cffile action="write" file="#myPath##genContent##fileName#" output="#genTrim(myContent)#" />

<!--- message.cfm - create index file main page...--->
<cfset fileName = "message.cfm" />
<cfsavecontent variable="myContent">
<!-- Message -->
<cfoutput>#l#cfdump var="##session##">
#l#cfdump var="##request##"></cfoutput>
</cfsavecontent>
<cfscript>writeRow('writing #fileName# file','#genContent##fileName#');</cfscript>
<cffile action="write" file="#myPath##genContent##fileName#" output="#genTrim(myContent)#" />

<!--- header.cfm - create header & navigation file to get to each page...--->
<cfset fileName = "header.cfm" />
<cfsavecontent variable="myContent">
<cfoutput>#l#cfoutput>
<head>
	<title>##request.appName##</title>
</head>
<div class="header"><a href="##request.appHome##">##request.appName##</a></div></cfoutput>
<ul id="nav2">
<cfoutput query="rs" group="Table_Name">
		<li><a href="##request.appHome###tabName(Table_Name)#">#dspFormat(Table_Name)#</a></li></cfoutput>
</ul><br clear="all" />
<cfoutput>#l#/cfoutput>

#l#cflock scope="session" timeout="10">
	#l#cfif isDefined("session.msg") and session.msg neq "">
		#l#cfset session.relaymessage.note = session.msg />
		#l#cfset session.relaymessage.type = session.msgtype />
		#l#cfset session.msg = "" />
	#l#/cfif>
	#l#cfif isDefined("session.relaymessage.note") and session.relaymessage.note neq "">
		#l#cfoutput>
			<div id="userMessage" class="##session.relaymessage.type##" 
				onclick="hideUserMsg();" title="Click to close this message.">
				##ucase(session.relaymessage.type)##:<br />
				##session.relaymessage.note##
			</div>
			<script language="javascript">
				// hide after 30 seconds
				var timer = window.setTimeout("hideUserMsg()",30*1000);
			</script>
		#l#/cfoutput>
		#l#cfset session.relaymessage.note = "" />
		#l#cfelse>
		<div id="userMessage" class="none" onclick="hideUserMsg();" title="Click to close this message."></div>
	#l#/cfif>
#l#/cflock></cfoutput>
</cfsavecontent>
<cfscript>writeRow('writing #fileName# file','#genContent##fileName#');</cfscript>
<cffile action="write" file="#myPath##genContent##fileName#" output="#genTrim(myContent)#" />

<!--- OnRequestEnd.cfm --->
<cfset fileName = "OnRequestEnd.cfm" />
<cfsavecontent variable="myContent">
	<div class="footer">
		<cfoutput>#l#cfoutput><a href="##request.appHome##">##request.appName##</a>#l#/cfoutput></cfoutput>
	</div>
	<cfif not isDefined("cookie.useCustomTagDate") 
			or (isDefined("cookie.useCustomTagDate") and cookie.useCustomTagDate eq 0)>
		<div id="calHolder" style="visibility:hidden;"></div>
		<script language="JavaScript">
			try {
				var myCal = new CalendarPopup("calHolder");
				myCal.showNavigationDropdowns();
			} catch (e) {}
		</script>
	</cfif>
</cfsavecontent>
<cfscript>writeRow('writing #fileName# file','#genContent##fileName#');</cfscript>
<cffile action="write" file="#myPath##genContent##fileName#" output="#genTrim(myContent)#" />

<!--- Copy over img, css and js files --->
<cfdirectory action="list" directory="#ExpandPath('img')#" name="origFiles" />
<cfif not DirectoryExists(ExpandPath('_generatedContent/img'))>
	<cfdirectory action="create" directory="#ExpandPath('_generatedContent/img')#" />
</cfif>
<cfloop query="origFiles">
	<cfif origFiles.type eq "file">
		<cffile action="copy" source="#ExpandPath('img')#\#origFiles.name#" destination="#ExpandPath('_generatedContent/img')#" />
	</cfif>	
</cfloop>

<cfdirectory action="list" directory="#ExpandPath('css')#" filter="*.css" name="origFiles" />
<cfif not DirectoryExists(ExpandPath('_generatedContent/css'))>
	<cfdirectory action="create" directory="#ExpandPath('_generatedContent/css')#" />
</cfif>
<cfloop query="origFiles">
	<cffile action="copy" source="#ExpandPath('css')#\#origFiles.name#" destination="#ExpandPath('_generatedContent/css')#" />	
</cfloop>

<cfdirectory action="list" directory="#ExpandPath('js')#" filter="*.js" name="origFiles" />
<cfif not DirectoryExists(ExpandPath('_generatedContent/js'))>
	<cfdirectory action="create" directory="#ExpandPath('_generatedContent/js')#" />
</cfif>
<cfloop query="origFiles">
	<cffile action="copy" source="#ExpandPath('js')#\#origFiles.name#" destination="#ExpandPath('_generatedContent/js')#" />	
</cfloop>

<caption>
	DONE!
</caption>


</table>
</cfprocessingdirective>